from selenium import webdriver
import time
from selenium.webdriver.common.by import By


driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://work.weixin.qq.com/")
# 设置隐式等待
driver.implicitly_wait(10)

# 点击-登录
driver.find_element(By.CLASS_NAME, "index_top_operation_loginBtn").click()
time.sleep(2)
# # 睡眠20秒等待扫码登录
# time.sleep(20)
#
# # 获取当前页面cookies
# print(driver.get_cookies())

cookies = [{'domain': '.work.weixin.qq.com', 'expiry': 1686320173.402672, 'httpOnly': False, 'name': 'wwrtx.i18n_lan', 'path': '/', 'secure': False, 'value': 'zh'}, {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.vst', 'path': '/', 'secure': False, 'value': 'iIfA-pDg8P9sJjHgQi_y4fdhupNlwSHSyO8_7QHKvAJI1AlEzXrKOTZBq2hMyAmXGkNWiX4Do2EZRPQUeieZ83jEG8gSiiOVlnLKqhZgOOQD3rPnl7FPsAF7Jdg04cD5LeFPTa3CVA-9hrHBWwhuxIYUeE0Tca69WLWLmeGNsqzH0JzVlwX22QqRTod0IFmn9csqeFcQT1_yHD2EAeL99j4VvNc-KIw1E-ey0ylGSAQwEr2JeRDXQs11_LnrAEQsqv-sjskSKR7J6lcuhsljyQ'}, {'domain': '.work.weixin.qq.com', 'expiry': 1715264160.90014, 'httpOnly': False, 'name': 'wwrtx.c_gdpr', 'path': '/', 'secure': False, 'value': '0'}, {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.ref', 'path': '/', 'secure': False, 'value': 'direct'}, {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.refid', 'path': '/', 'secure': False, 'value': '0961218'}, {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wwrtx.vid', 'path': '/', 'secure': False, 'value': '1688858211371146'}, {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wwrtx.d2st', 'path': '/', 'secure': False, 'value': 'a149669'}, {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.ltype', 'path': '/', 'secure': False, 'value': '1'}, {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.sid', 'path': '/', 'secure': False, 'value': 'lanyrmqDIWwVSFavtSOE4ehbV6aUuZ-9pYLo89pLEOH1RPKE8qCVNE6OacFU6bfi'}, {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wxpay.corpid', 'path': '/', 'secure': False, 'value': '1970325261984975'}, {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wxpay.vid', 'path': '/', 'secure': False, 'value': '1688858211371146'}, {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wwrtx.cs_ind', 'path': '/', 'secure': False, 'value': ''}, {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.logined', 'path': '/', 'secure': False, 'value': 'true'}]
# 设置cookie,绕过登录
for cookie in cookies:
    driver.add_cookie(cookie)

driver.refresh()

time.sleep(5)
driver.quit()